﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Props.Backend
{
    public enum OperationEnum
    {
        [Description("Venta")]
        Sale = 1,

        [Description("Alquiler")]
        Rental = 2,

        [Description("Alquiler Temporario")]
        TemporaryRental = 3,

        [Description("Emprendimiento")]
        Entrepreneurship = 4
    }

    public enum PropertyTypeEnum
    {
        [Description("Departamentos")]
        Departamentos = 1,

        [Description("Casas")]
        Casas = 2,

        [Description("PH")]
        PH = 3,

        [Description("Countries y Barrios Cerrados")]
        Countries_BarriosCerrados = 4,

        [Description("Quintas")]
        Quintas = 5,

        [Description("Terrenos y Lotes")]
        Terrenos_Lotes = 6,

        [Description("Campos y Chacras")]
        Campos_Chacras = 7,

        [Description("Galpones, Depositos y Edificios Ind.")]
        Galpones_Depositos_Edificios_Ind= 8,

        [Description("Locales Comerciales")]
        Locales_Comerciales = 9,

        [Description("Negocios y Fondos de Comercio")]
        Negocios_FondosComercio = 10,

        [Description("Oficinas")]
        Oficinas = 11,

        [Description("Consultorios")]
        Consultorios = 12,

        [Description("Cocheras")]
        Cocheras = 13,

        [Description("Bovedas, Nichos y Parcelas")]
        Bovedas_Nichos_Parcelas = 15
    }

    public enum RoomsEnum
    {
        [Description("1 Ambiente")]
        _1Room = 1,
        
        [Description("2 Ambientes")]
        _2Rooms = 2,

        [Description("3 Ambientes")]
        _3Rooms = 3,

        [Description("4 Ambientes")]
        _4Rooms = 4,

        [Description("5 o más")]
        _5orMoreRooms = 5
    }

    public static class EnumExtensions
    {
        public static string GetDisplayName<T>(this T value)
        {
            if (!value.GetType().IsEnum)
            {
                throw new NotSupportedException("TResult must be an Enum");
            }
            try
            {
                var type = value.GetType();
                var memInfo = type.GetMember(value.ToString());
                var attributes = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute),
                    false);
                var description = ((DescriptionAttribute)attributes[0]).Description;

                return description;
            }
            catch
            {
                return Enum.GetName(value.GetType(), value);
            }
        }
    }
}
